import request from "@/utils/request";

export interface AttrValueData {
  id?: number;
  valueName: string;
  attrId: number | undefined;
  isEdit?: boolean;
}

export type AttrData = {
  id?: number;
  attrName: string;
  categoryId: number | string;
  categoryLevel: number;
  attrValueList: AttrValueData[];
  attrIdValueId?: string;
};

export default {
  // GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
  // attrInfoList
  getList(category1Id: number, category2Id: number, category3Id: number) {
    return request.get<any, AttrData[]>(
      `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`
    );
  },
  // DELETE /admin/product/deleteAttr/{attrId}
  // deleteAttr
  delete(attrId: number) {
    return request.delete(`/admin/product/deleteAttr/${attrId}`);
  },
  // POST /admin/product/saveAttrInfo
  addOrUpdate(attr: AttrData) {
    return request.post("/admin/product/saveAttrInfo", attr);
  },
};
